package com.gill.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gill.exception.CommonServiceException;
import com.gill.service.CinemaService;
import com.gill.vo.BasePageVO;
import com.gill.vo.BaseResponseVO;
import com.gill.vo.CinemaSavedReqVO;
import com.gill.vo.DescribeCinemasRespVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/cinema")
@RestController
public class CinemaController {

    @Autowired
    private CinemaService cinemaService;

    /**
     * 新增影院
     */
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public BaseResponseVO saveCinema(@RequestBody CinemaSavedReqVO cinemaSavedReqVO) throws CommonServiceException {

        // 数据验证
        cinemaSavedReqVO.checkParam();

        cinemaService.saveCinema(cinemaSavedReqVO);

        return BaseResponseVO.success();
    }

    /**
     *
     */
    @RequestMapping(value = "",method = RequestMethod.GET)
    public BaseResponseVO describeCinemas(BasePageVO basePageVO) throws CommonServiceException {

        IPage<DescribeCinemasRespVO> describeCinemasRespVOIPage = cinemaService.describeCinemas(basePageVO.getNowPage(), basePageVO.getPageSize());

        // TODO 调用封装的分页返回方法

        return BaseResponseVO.success();
    }
}
